﻿// Decompiled with JetBrains decompiler
// Type: UnityEngine.SkinnedMeshRenderer
// Assembly: UnityEngine.CoreModule, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
// MVID: E6AE6B5A-2752-4B07-9528-C8B77C62CE79
// Assembly location: C:\Users\windys\Unity\2021.3.39f1c1\Editor\Data\Managed\UnityEngine\UnityEngine.CoreModule.dll
// XML documentation location: C:\Users\windys\Unity\2021.3.39f1c1\Editor\Data\Managed\UnityEngine\UnityEngine.CoreModule.xml

using System;
using System.Runtime.CompilerServices;
using UnityEngine.Bindings;
using UnityEngine.Scripting;

#nullable disable
namespace UnityEngine
{
  /// <summary>
  ///   <para>The Skinned Mesh filter.</para>
  /// </summary>
  [NativeHeader("Runtime/Graphics/Mesh/SkinnedMeshRenderer.h")]
  [RequiredByNativeCode]
  public class SkinnedMeshRenderer : Renderer
  {
    /// <summary>
    ///   <para>The maximum number of bones per vertex that are taken into account during skinning.</para>
    /// </summary>
    public extern SkinQuality quality { [MethodImpl(MethodImplOptions.InternalCall)] get; [MethodImpl(MethodImplOptions.InternalCall)] set; }

    /// <summary>
    ///   <para>If enabled, the Skinned Mesh will be updated when offscreen. If disabled, this also disables updating animations.</para>
    /// </summary>
    public extern bool updateWhenOffscreen { [MethodImpl(MethodImplOptions.InternalCall)] get; [MethodImpl(MethodImplOptions.InternalCall)] set; }

    /// <summary>
    ///   <para>Forces the Skinned Mesh to recalculate its matricies when rendered</para>
    /// </summary>
    public extern bool forceMatrixRecalculationPerRender { [MethodImpl(MethodImplOptions.InternalCall)] get; [MethodImpl(MethodImplOptions.InternalCall)] set; }

    public extern Transform rootBone { [MethodImpl(MethodImplOptions.InternalCall)] get; [MethodImpl(MethodImplOptions.InternalCall)] set; }

    internal extern Transform actualRootBone { [MethodImpl(MethodImplOptions.InternalCall)] get; }

    /// <summary>
    ///   <para>The bones used to skin the mesh.</para>
    /// </summary>
    public extern Transform[] bones { [MethodImpl(MethodImplOptions.InternalCall)] get; [MethodImpl(MethodImplOptions.InternalCall)] set; }

    /// <summary>
    ///   <para>The mesh used for skinning.</para>
    /// </summary>
    [NativeProperty("Mesh")]
    public extern Mesh sharedMesh { [MethodImpl(MethodImplOptions.InternalCall)] get; [MethodImpl(MethodImplOptions.InternalCall)] set; }

    /// <summary>
    ///   <para>Specifies whether skinned motion vectors should be used for this renderer.</para>
    /// </summary>
    [NativeProperty("SkinnedMeshMotionVectors")]
    public extern bool skinnedMotionVectors { [MethodImpl(MethodImplOptions.InternalCall)] get; [MethodImpl(MethodImplOptions.InternalCall)] set; }

    /// <summary>
    ///   <para>Returns the weight of a BlendShape for this Renderer.</para>
    /// </summary>
    /// <param name="index">The index of the BlendShape whose weight you want to retrieve. Index must be smaller than the Mesh.blendShapeCount of the Mesh attached to this Renderer.</param>
    /// <returns>
    ///   <para>The weight of the BlendShape.</para>
    /// </returns>
    [MethodImpl(MethodImplOptions.InternalCall)]
    public extern float GetBlendShapeWeight(int index);

    /// <summary>
    ///   <para>Sets the weight of a BlendShape for this Renderer.</para>
    /// </summary>
    /// <param name="index">The index of the BlendShape to modify. Index must be smaller than the Mesh.blendShapeCount of the Mesh attached to this Renderer.</param>
    /// <param name="value">The weight for this BlendShape.</param>
    [MethodImpl(MethodImplOptions.InternalCall)]
    public extern void SetBlendShapeWeight(int index, float value);

    /// <summary>
    ///   <para>Creates a snapshot of SkinnedMeshRenderer and stores it in mesh.</para>
    /// </summary>
    /// <param name="mesh">A static mesh that will receive the snapshot of the skinned mesh.</param>
    /// <param name="useScale">Whether to use the SkinnedMeshRenderer's Transform scale when baking the Mesh. If this is true, Unity bakes the Mesh using the position, rotation, and scale values from the SkinnedMeshRenderer's Transform. If this is false, Unity bakes the Mesh using the position and rotation values from the SkinnedMeshRenderer's Transform, but without using the scale value from the SkinnedMeshRenderer's Transform. The default value is false.</param>
    public void BakeMesh(Mesh mesh) => this.BakeMesh(mesh, false);

    /// <summary>
    ///   <para>Creates a snapshot of SkinnedMeshRenderer and stores it in mesh.</para>
    /// </summary>
    /// <param name="mesh">A static mesh that will receive the snapshot of the skinned mesh.</param>
    /// <param name="useScale">Whether to use the SkinnedMeshRenderer's Transform scale when baking the Mesh. If this is true, Unity bakes the Mesh using the position, rotation, and scale values from the SkinnedMeshRenderer's Transform. If this is false, Unity bakes the Mesh using the position and rotation values from the SkinnedMeshRenderer's Transform, but without using the scale value from the SkinnedMeshRenderer's Transform. The default value is false.</param>
    [MethodImpl(MethodImplOptions.InternalCall)]
    public extern void BakeMesh([NotNull("NullExceptionObject")] Mesh mesh, bool useScale);

    /// <summary>
    ///   <para>Retrieves a GraphicsBuffer that provides direct access to the GPU vertex buffer for this skinned mesh, for the current frame.</para>
    /// </summary>
    /// <returns>
    ///   <para>The skinned mesh vertex buffer as a GraphicsBuffer.</para>
    /// </returns>
    public GraphicsBuffer GetVertexBuffer()
    {
      if ((Object) this == (Object) null)
        throw new NullReferenceException();
      GraphicsBuffer vertexBufferImpl = this.GetVertexBufferImpl();
      vertexBufferImpl?.AddBufferToLeakDetector();
      return vertexBufferImpl;
    }

    /// <summary>
    ///   <para>Retrieves a GraphicsBuffer that provides direct access to the GPU vertex buffer for this skinned mesh, for the previous frame.</para>
    /// </summary>
    /// <returns>
    ///   <para>The skinned mesh vertex buffer as a GraphicsBuffer.</para>
    /// </returns>
    public GraphicsBuffer GetPreviousVertexBuffer()
    {
      if ((Object) this == (Object) null)
        throw new NullReferenceException();
      GraphicsBuffer vertexBufferImpl = this.GetPreviousVertexBufferImpl();
      vertexBufferImpl?.AddBufferToLeakDetector();
      return vertexBufferImpl;
    }

    [FreeFunction(Name = "SkinnedMeshRendererScripting::GetVertexBufferPtr", HasExplicitThis = true)]
    [MethodImpl(MethodImplOptions.InternalCall)]
    private extern GraphicsBuffer GetVertexBufferImpl();

    [FreeFunction(Name = "SkinnedMeshRendererScripting::GetPreviousVertexBufferPtr", HasExplicitThis = true)]
    [MethodImpl(MethodImplOptions.InternalCall)]
    private extern GraphicsBuffer GetPreviousVertexBufferImpl();

    /// <summary>
    ///   <para>The intended target usage of the skinned mesh GPU vertex buffer.</para>
    /// </summary>
    public extern GraphicsBuffer.Target vertexBufferTarget { [MethodImpl(MethodImplOptions.InternalCall)] get; [MethodImpl(MethodImplOptions.InternalCall)] set; }
  }
}
